//当前这个模块：API进行统一管理
import requests from "./ajax";
import mockRequest from './mockAjax'

//封装一个函数---获取三级联动接口
// /api/product/getBaseCategoryList
export const insCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' })

// 获取虚拟数据banner
export const reqBannerList = () => mockRequest.get('/banner')

//获取虚拟数据floor
export const reqFloorList = () => mockRequest.get('/floor')

//获取搜索数据  接口地址/api/list
//当前这个接口给服务器传递参数，params至少是一个空对象
export const reqSearchList = (params)=>requests({
    url:'/list',
    method:'post',
    data:params
})

//封装一个函数---获取详情页面数据
export const reqGoodInfo=(skuId)=>requests.get(`/item/${ skuId }`)

//封装一个函数---新增更新购物车数据
export const reqAddOrUpdateShopCart=(skuId,skuNum)=>requests.post(`/cart/addToCart/${skuId}/${skuNum}`)

//注册服务器接口-->购物车数据
export const reqCartList=()=>requests.get('/cart/cartList')

//删除购物车
export const reqDeleteCartBySkuId=(skuId)=>requests.delete(`/cart/deleteCart/${skuId}`)

//修改产品状态
export const reqUpdateCheckedById=(skuId,isChecked)=>requests.get(`/cart/checkCart/${skuId}/${isChecked}`)

//获取验证码
export const reqUserCode=(phone)=>requests.get(`/user/passport/sendCode/${phone}`)

//注册
export const reqUserRegister=(data)=>requests.post(`/user/passport/register`,data)

//登录
export const reqUserLogin=(data)=> requests.post('/user/passport/login',data)

//获取用户信息
export const reqUserInfo=()=>requests.get('/user/passport/auth/getUserInfo')

//退出登录
export const reqLogout=()=>requests.get('/user/passport/logout')

//获取用户地址信息---虚拟数据
export const reqAddressInfo=()=>mockRequest.get('/address')
//获取交易页商品清单
export const reqOrderInfo=()=>requests.get('/order/auth/trade')

//提交订单接口---传递两个参数tradeNo,data---返回订单号
export const reqSubmitOrder=(tradeNo,data)=>requests.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,data)

//获取订单支付信息
export const reqPayInfo=(orderId)=>requests.get(`/payment/weixin/createNative/${orderId}`)

//获取支付状态
export const reqPayStatus=(orderId)=>requests.get(`/payment/weixin/queryPayStatus/${orderId}`)

//获取我的订单列表
export const reqOrderList=(page,limit)=>requests.get(`/order/auth/${page}/${limit}`)